import 'package:auto_route/auto_route.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../config/Config.dart';

class CommonUtils {
  static PreferredSizeWidget getAppBar(String title, VoidCallback onBack) {
    return AppBar(
      backgroundColor: Colors.white,
      centerTitle: true,
      title: Text(title),
      leading: BackButton(
        onPressed: onBack,
        color: Config.color17,
      ),
    );
  }

  static Widget getImageAsset(String image, {double? width,BoxFit? fit,Color? color }) {
    if (width != null) {
      return Image.asset(
        "asset/images/$image.png",
        width: width,
        fit: fit,
        color: color,
      );
    }
    return Image.asset("asset/images/$image.png");
  }

  static void go(BuildContext context, PageRouteInfo pageRoute) {
    context.router.push(pageRoute);
  }

  static void back(BuildContext context) {
    Navigator.of(context).pop();
  }

  static void openModalBottomSheet(BuildContext context,
      {required Widget child}) {
    showModalBottomSheet(
      context: context,
      builder: (BuildContext context) {
        return child;
      },
    );
  }
}